package gooeys;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

public class Gooey extends JFrame implements ActionListener
{
	JPanel my_panel;
	JButton my_button;
	JLabel my_label;
	JLabel my_label2;
	JLabel my_label3;
	JLabel my_label4;
	JLabel my_label5;
	JButton another_button;
	JPanel panel2;
	JPanel panel3;
	JPanel panel4;
	JPanel panel5;
	JPanel equal;
	JTextField text;
	JTextField text2;
	JTextField text3;
	JTextField answer;
	
	public void setUpPanel()
	{
		my_panel = new JPanel();
		my_button = new JButton("=");
		my_label = new JLabel("Number 1");
		my_label2 = new JLabel("Number 2");
		my_label3 = new JLabel("Operator");
		my_label4 = new JLabel("Answer");
		my_label5 = new JLabel(" ");
		another_button=new JButton("=");
		my_button.addActionListener(this);
		panel2 = new JPanel();
		panel3 = new JPanel();
		panel4 = new JPanel();
		panel5 = new JPanel();
		equal = new JPanel();
		text = new JTextField();
		text2 = new JTextField();
		text3 = new JTextField();
		answer = new JTextField();
		BorderLayout layout = new BorderLayout();
		BorderLayout layout2 = new BorderLayout();
		BorderLayout layout3 = new BorderLayout();
		BorderLayout layout4 = new BorderLayout();
		BorderLayout layout5 = new BorderLayout();
		equal.setLayout(layout5);
		panel2.setLayout(layout);
		panel3.setLayout(layout2);
		panel4.setLayout(layout3);
		panel5.setLayout(layout4);
		panel3.add(my_label, layout2.NORTH);
		panel3.add(text, layout2.SOUTH);
		panel4.add(my_label2, layout3.NORTH);
		panel4.add(text2, layout3.SOUTH);
		panel2.add(my_label3, layout.NORTH);
		panel2.add(text3, layout.SOUTH);
		panel5.add(my_label4, layout4.NORTH);
		panel5.add(answer, layout4.SOUTH);
		equal.add(my_label5, layout5.NORTH);
		equal.add(my_button, layout5.SOUTH);

	}
	
	
	public Gooey()
	{
		setTitle("WHAT IS THIS?");
		setSize(300,100);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		
		setUpPanel();
		this.add(my_panel);
		my_panel.add(panel3);
		my_panel.add(panel4);
		my_panel.add(panel2);
		my_panel.add(equal);
		my_panel.add(panel5);
	}
	
	public static void main(String[] args)
	{
		Gooey goo = new Gooey();
		goo.setVisible(true);
	}


	@Override
	public void actionPerformed(ActionEvent arg0) {
		// TODO Auto-generated method stub
		String input = text.getText();
		double num1=Double.parseDouble(input);
		input = text2.getText();
		double num2=Double.parseDouble(input);
		input = text3.getText();
		if(input.compareTo("+")==0)
		{
			
			answer.setText(String.valueOf(num1+num2));
		}
		if(input.compareTo("-")==0)
		{
			
			answer.setText(String.valueOf(num1-num2));
		}
		if(input.compareTo("*")==0)
		{
			
			answer.setText(String.valueOf(num1*num2));
		}
		if(input.compareTo("/")==0)
		{
			
			answer.setText(String.valueOf(num1/num2));
		}

	}
}
